package cn.kilo.domain.service.order.factory;

import cn.kilo.domain.service.order.IStaffStrategyChain;
import lombok.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @author kilok
 */
@Service
@Slf4j
public class DefaultFactory {

    private final Map<String, IStaffStrategyChain> staffGroup;


    public DefaultFactory(Map<String, IStaffStrategyChain> staffGroup) {
        this.staffGroup = staffGroup;
    }

    public IStaffStrategyChain getChain(String role) {
        return staffGroup.get(role);
    }


    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    public static class StaffVO {
        private String role;
        private String staffId;
    }


    @Getter
    @AllArgsConstructor
    public enum Role {

        SORTER1("sorter1", "分拣员1"), SORTER2("sorter2", "分拣员2"), GUARD("guard", "保安"), USER("user", "用户"), OVER("over", "结束");

        private final String code;

        private final String info;

    }

    @Getter
    @AllArgsConstructor
    public enum Status {

        CREATE("user", "订单创建成功，正在等待支付"),
        FAIL("fail", "订单创建失败"),
        PAY("pay","支付成功，正在分配订单"),
        PAY_FAIL("pay_fail","订单超出支付时间，删除订单不再分配"),

        FAIL_GET_ORDER("fail", "已经有其他楼栋的订单，不可接取本订单"),
        FAIL_NO_ORDER("fail", "该订单已经被其他骑手接取"),
        WRONG_POSITION("fail", "订单创建失败-该区域不可配送"),
        WRONG_DEPARTMENT("fail", "订单创建失败-错误的公寓地址"),
        WRONG_FLOOR("fail", "订单创建失败-错误的楼层信息"),
        FAIL_TAKE_ORDER("fail", "订单接取失败"),
        FAIL_OVER_ODER("fail", "订单结束失败，还未上传物件照片"),
        NO_SORTER("fail", "本楼栋没有骑手接单，无法自动分配，请耐心等待其他骑手接单，或联系管理员"),

        TAKE_1("sorter1", "订单被接取,正在送至寝室楼下"),
        TAKE_2("guard", "订单在寝室楼下，等待送上对应寝室"),
        TAKE_3("sorter2", "订单正在送至对应寝室，就快要到达了"),
        OVER("over", "物件已经送至对应寝室门口"),
        CONFIRM("confirm", "用户确认收货"),
        UN_ERROR("false", "订单接取失败"),

        ;
        private final String code;

        private final String info;
    }
}
